<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>已领取优惠券</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">

                        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <label class="layui-form-label">领取用户ID</label>
                                    <div class="layui-input-block">
                                        <input class="layui-input" name="userId" placeholder="请输入领取用户ID" autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">领取手机号</label>
                                    <div class="layui-input-block" >
                                        <input class="layui-input" name="mobile" placeholder="请输入领取用户手机号" autocomplete="off">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">派发用户ID</label>
                                    <div class="layui-input-block" style="width: 300px;">
                                        <input class="layui-input" name="dispatchUserId" placeholder="请输入派发用户ID" autocomplete="off">
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">领券时间</label>
                                    <div class="layui-input-block">
                                        <div class="layui-inline"><input style="width: 180px;" type="text" id="startCreateTime" name="startCreateTime" placeholder="开始日时间" autocomplete="off" class="layui-input"></div>
                                        <div class="layui-inline">—</div>
                                        <div class="layui-inline"><input style="width: 180px;" type="text" id="endCreateTime" name="endCreateTime" placeholder="结束时间" autocomplete="off" class="layui-input"></div>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">用券时间</label>
                                    <div class="layui-input-block">
                                        <div class="layui-inline"><input style="width: 180px;" type="text" id="startUseTime" name="startDonateTime" placeholder="开始时间" autocomplete="off" class="layui-input"></div>
                                        <div class="layui-inline">—</div>
                                        <div class="layui-inline"><input style="width: 180px;" type="text" id="endUseTime" name="endDonateTime" placeholder="结束时间" autocomplete="off" class="layui-input"></div>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-search">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"> 搜索</i>
                                    </button>
                                </div>
                            </div>
                        </div>

                        <table class="layui-hide" id="test-table-reload" lay-filter="test-table-reload"></table>
                        <script type="text/html" id="test-table-reload-toolbar">
                            <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="returnCoupon"><i class="layui-icon layui-icon-return"></i>返回优惠券</button>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="couponId" value="${id}">
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','utils', 'form','laydate'], function(){
        var $ = layui.$,
                table = layui.table,
                form = layui.form,
                laydate= layui.laydate;


        //监听搜索
        form.on("submit(LAY-search)", function (data) {
            var field = data.field;

            //执行重载
            table.reload('test-table-reload', {
                where: field
            });
        });

        //头工具栏事件
        table.on('toolbar(test-table-reload)', function(obj){
            if(obj.event === 'returnCoupon'){
                window.location.href="/coupon/list";
            }
        });

        laydate.render({
            elem: '#startCreateTime'
            ,type: 'datetime'
            ,format:'yyyy-MM-dd HH:mm:ss'
        });

        laydate.render({
            elem: '#endCreateTime'
            ,type: 'datetime'
            ,format:'yyyy-MM-dd HH:mm:ss'
        });

        laydate.render({
            elem: '#startUseTime'
            ,type: 'datetime'
            ,format:'yyyy-MM-dd HH:mm:ss'
        });

        laydate.render({
            elem: '#endUseTime'
            ,type: 'datetime'
            ,format:'yyyy-MM-dd HH:mm:ss'
        });

        //方法级渲染
        table.render({
            elem: '#test-table-reload'
            ,url: "/coupon/getCouponUserList?id="+$("#couponId").val()
            ,toolbar: '#test-table-reload-toolbar'
            ,defaultToolbar:['filter']
            ,cellMinWidth: 80
            ,cols: [[
                {field:'userId', title: '领取用户ID', fixed: true},
                {field:'userName', title: '领取用户昵称'},
                {field:'dispatchUserId', title: '派券用户ID'},
                {field:'dispatchUserName', title: '派券用户昵称'}
                , {field:'getWayName', title: '领取方式'}
                , {field:'couponCodeName', title: '券码'}
                , {field:'createTime', title: '领取时间',sort: true,templet: function (d) {
                        return "<div>"+layui.toDateString(d.createTime)+"</div>";
                    }}
                , {field:'useTime', title: '用券时间',sort: true,templet: function (d) {
                        if (d.useTime > 0) {
                            return "<div>"+layui.toDateString(d.useTime)+"</div>";
                        } else {
                            return "<div style='text-align: center'>"+"-------"+"</div>";
                        }
                    }}
                , {field:'orderNo', title: '订单号',templet: function (d) {
                        if (d.orderId > 0) {
                            return "<div>"+d.orderNo+"</div>";
                        } else {
                            return "<div style='text-align: center'>"+"-------"+"</div>";
                        }
                    }}
            ]]
            ,page: true
            ,height: 524
        });


    });
</script>
</body>
</html>